package com.wanxi.education.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanxi.education.mapper.AdvertMapper;
import com.wanxi.education.model.vo.advertandcertificate.AdvertAddVo;
import com.wanxi.education.model.vo.advertandcertificate.AdvertFindPageVo;
import com.wanxi.education.model.vo.advertandcertificate.AdvertVo;
import com.wanxi.education.service.AdvertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: yanguangqiong
 * @Description:
 * @Date: Created in 2021/9/24
 * @Version: 1.0
 */
@Service
public class AdvertServiceImpl implements AdvertService {
    @Autowired AdvertMapper advertMapper;
    @Override
    public PageInfo<AdvertAddVo> findPage(AdvertFindPageVo advertFindPageVO) {
        PageHelper.startPage(advertFindPageVO.getPageNum(),advertFindPageVO.getPageSize());
        List<AdvertAddVo> list = advertMapper.findPage();
        PageInfo<AdvertAddVo> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public AdvertAddVo findById(Long advertId) {
        AdvertAddVo byId = advertMapper.findById(advertId);
        return byId;
    }

    @Override
    public void add(AdvertAddVo advertAddVo) {
        advertMapper.add(advertAddVo);
    }

    @Override
    public void update(AdvertAddVo advertAddVo) {
        advertMapper.update(advertAddVo);
    }

    @Override
    public void delete(Long advertId) {
        advertMapper.delete(advertId);
    }

//    显示广告轮播
    @Override
    public PageInfo<AdvertVo> findPageForFront() {
            PageHelper.startPage(0,3);
            List<AdvertVo> list = advertMapper.findPageForFront();
            PageInfo<AdvertVo> advertVoPageInfo = new PageInfo<>(list);
            return advertVoPageInfo;
    }
}
